import Socket from "./Socket";
import GlobalData from "./GlobalData";
import QueryUrl from "./QueryUrl";

// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        GlobalData.to_id = QueryUrl.getQueryVariable('fromid');
    }

    start () {
        let self = this;
        setTimeout(function(){
            self.sendMessageToScreen();
        },1500);
        
    }

    sendMessageToScreen(){       

        let socket = this.getComponent(Socket);

        let data = {'action':'start'};        

        socket.sendMessageToId(data, GlobalData.to_id);

    }

    // update (dt) {}
}
